/************************************************************************
 * @file PluginFactory.h
 * @author Ian Chen
 * @version 1.0
 *
 * @section LICENSE
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
 * General Public License for more details at
 * http://www.gnu.org/licenses/lgpl.html
 *
 ************************************************************************/
#ifndef PLUGINFACTORY_H
#define PLUGINFACTORY_H

#include <map>
using namespace std;

#include <QMetaObject>

#include <plugin/plugin_global.h>
#include <plugin/plugin/PluginDescription.h>

namespace antu
{
namespace plugin
{
class AbstractPlugin;
class ServiceRegistry;
}
}

typedef antu::plugin::AbstractPlugin* (*pPluginInstantiationFunc)(
        antu::plugin::PluginDescriptionSharedPtr& description,
        antu::plugin::ServiceRegistry* pService);

namespace antu
{
namespace plugin
{

class PLUGINSHARED_EXPORT PluginFactory
{
private:
    PluginFactory();

    map<QString, pPluginInstantiationFunc> m_oPluginInfos;

public:
    ~PluginFactory();

    static PluginFactory Factory;

    bool registerPluginInfo(const QString& pluginCode, pPluginInstantiationFunc pInstantiationFunc);

    AbstractPlugin* createPlugin(const QString& pluginCode,
                                 PluginDescriptionSharedPtr& description,
                                 ServiceRegistry* pRegistry,
                                 QObject* pParent);
};

}
}

#endif // PLUGINFACTORY_H
